package com.wnhz.work.jy.activity;

import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.wnhz.work.jy.BaseActivity;
import com.wnhz.work.jy.R;
import com.wnhz.work.jy.adapter.CouponAdapter;
import com.wnhz.work.jy.bean.CouponBean;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * ----优惠券
 */
public class CouponActivity extends BaseActivity implements View.OnClickListener {
    private TextView title;
    private ListView lv_coupon;
    private CouponAdapter mAdapter;

    private List<CouponBean> couponList = new ArrayList<>();

    @ViewInject(R.id.include_occupied)
    private View include_occupied;
    @ViewInject(R.id.blank_img)
    private ImageView blank_img;
    @ViewInject(R.id.blank_tv)
    private TextView blank_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_coupon);
        x.view().inject(this);
        initView();
        setBlank();
    }

    private void setBlank() {
        if (couponList.size() == 0) {
            blank_tv.setText("新的优惠券马上来~");
            blank_img.setImageResource(R.mipmap.ic_youhuijuanweikong);
            include_occupied.setVisibility(View.VISIBLE);
        } else {
            include_occupied.setVisibility(View.GONE);
        }
    }

    private void initView() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("优惠券");
        findViewById(R.id.btn_main_left).setOnClickListener(this);

        lv_coupon = (ListView) findViewById(R.id.lv_coupon);

        mAdapter = new CouponAdapter(this, couponList);
        lv_coupon.setAdapter(mAdapter);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_main_left:
                finish();
                break;

            default:
                break;
        }
    }
}
